const actions = {
  addCart(context, info) {
    return new Promise(function(resolve, reject) {
      // 1.查看是否添加过
    const oldInfo = context.state.cartList.find(item => item.iid === info.iid)

    // 2.+1或者新添加
    if (oldInfo) {
      oldInfo.count += 1
      resolve('商品数量+1')
    } else {
      info.count = 1
      info.checked = true
      context.state.cartList.push(info)
      resolve('加入购物车成功')
    }
    })

  }
}

export default actions

